/*
 * Expression.h
 *
 *  Created on: Aug 7, 2011
 *      Author: dino
 */

#ifndef EXPRESSION_H_
#define EXPRESSION_H_
#include <vector>
#include <iostream>

class FracEx;
class IntegerEx;

using namespace std;

class Expression {
private:
	vector<Expression*>		operands;
protected:
	Expression*				parent;
public:
	Expression();
	virtual ~Expression();

	void addOperand(Expression* operand);
	void replaceOperand(Expression* original, Expression* replacement);
	Expression* getOperand(int index);
	bool simplifyOperands();

	virtual bool simplify() = 0;
	virtual Expression* add(Expression* expression) = 0;
	virtual Expression* substract(Expression* expression) = 0;

	virtual Expression* addToInteger(IntegerEx* integer) {return NULL;}
	virtual Expression* substractFromInteger(IntegerEx* integer) {return NULL;}
	virtual Expression* addToFrac(IntegerEx* integer) {return NULL;}
	virtual Expression* substractFromFrac(IntegerEx* integer) {return NULL;}

	virtual void toString(ostream& out) = 0;

};

#endif /* EXPRESSION_H_ */
